<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="__ROOT__/static/plugins/bootstrap/css/bootstrap.css">
    <script src="__ROOT__/static/plugins/jquery-3.2.1/jquery-3.2.1.min.js"></script>
    <script src="__ROOT__/static/plugins/layer/layer.min.js"></script>
</head>
<style>
    a{ color:#fcfcfc; text-decoration: none; }
    a:link {
        text-decoration:none;
    }
    a:visited {
        text-decoration:none;
    }
    a:hover {
        text-decoration:none;
    }
    a:active {
        text-decoration:none;
    }
</style>
<body>
<div  style="text-align: right;"  >
    <a href="{:url('Admin/Goodscats/addFirstCats')}" >
<button class="btn btn-success dropdown-toggle wst-btn-dropdown" type="button" data-toggle="dropdown">
    新增一级分类
</button>
    </a>
</div>
<table border="1" class="wst-list table table-hover table-striped table-bordered"
       cellspacing="0" width="100%">
    <tr style=" height: 20px">
        <td style="width: 40%; height: 20px">分类名称</td>
        <td style="width: 5%; height: 20px">商品id</td>
        <td style="width: 5%; height: 20px">是否显示</td>
        <td style="width: 30%; height: 20px">操作</td>
    </tr>
    {volist name="rows" id="data" key="i"}
    <!-- 一级分类start -->
    <tr>
        <td>
            <span class="glyphicon glyphicon-minus" onclick="show(this,'tr_{$i}')" style="cursor: pointer"></span>
            {$data['type_name']}
        </td>
        <td>{$data['id']}</td>
        <td>
            <button class="btn btn-success dropdown-toggle wst-btn-dropdown" type="button"
                    data-toggle="dropdown">
                显示
            </button>
        </td>
        <td>
            <a href="{:url('Admin/Goodscats/addChildCart',array('id'=>$data['id']))}" >
            <button class="btn btn-success dropdown-toggle wst-btn-dropdown" type="button" data-toggle="dropdown">
                新增二级分类
            </button>
            </a>&nbsp;&nbsp;&nbsp;
            <a class="btn btn-danger glyphicon glyphicon-trash"    onclick="delGoodsCats({$data['id']})">删除</a>
            &nbsp;&nbsp;&nbsp;
            <a   href="{:url('Admin/Goodscats/updateCat',array('id'=>$data['id']))}"
                    class="btn btn-info glyphicon glyphicon-pencil">修改</a>

        </td>
    </tr>
    <!-- 一级分类end -->
    <!-- 二级分类start -->
    {volist name="data['data']" id="d" key="i2"}
        <tr class="tr_{$i}">
            <td>
                <span class="glyphicon glyphicon-minus" onclick="show(this,'tr_{$i}_{$i2}')"
                      style='margin-right:3px;margin-left:30px; cursor: pointer  '></span>
                {$d['type_name']}
            </td>
            <td>{$d['id']}</td>
            <td>
                <button class="btn btn-success dropdown-toggle wst-btn-dropdown" type="button" data-toggle="dropdown">
                    显示
                </button>
            </td>
            <td>
                <a href="{:url('Admin/Goodscats/addChildCart',array('id'=>$d['id']))}" >
                <button class="btn btn-success dropdown-toggle wst-btn-dropdown" type="button" data-toggle="dropdown">
                新增三级分类
                </button>
                </a>&nbsp;&nbsp;&nbsp;
                <a class="btn btn-danger glyphicon glyphicon-trash"    onclick="delGoodsCats({$d['id']})">删除</a>
                &nbsp;&nbsp;&nbsp;
                <a   href="{:url('Admin/Goodscats/updateCat',array('id'=>$d['id']))}"
                        class="btn btn-info glyphicon glyphicon-pencil"  >修改</a>
            </td>
        </tr>
        <!-- 二级分类end -->
        <!-- 三级分类start -->
        {volist name="d['data']" id="vo" key="i3"}
            <tr class="tr_{$i}_{$i2}">
                <td>
                    <span class="glyphicon glyphicon-minus" style='margin-right:3px;margin-left:60px; cursor: pointer   '></span>
                    {$vo['type_name']}
                </td>
                <td>{$vo['id']}</td>
                <td>
                    <button class="btn btn-success dropdown-toggle wst-btn-dropdown" type="button" data-toggle="dropdown">
                        显示
                    </button>
                    &nbsp;&nbsp;&nbsp;
                </td>
                <td>
                    <a class="btn btn-danger glyphicon glyphicon-trash"    onclick="delGoodsCats({$vo['id']})">删除</a>
                    &nbsp;&nbsp;&nbsp;
                    <a   href="{:url('Admin/Goodscats/updateCat',array('id'=>$vo['id']))}"
                            class="btn btn-info glyphicon glyphicon-pencil"  >修改</a>
                </td>
            </tr>
        {/volist}
        <!-- 三级分类end -->
    {/volist}
    {/volist}
</table>

</body>
<script>
    //新增子分类
    function addChildCart(id){
        var params={};
        params.id=id;
    }
    function show(obj, keyyy) {
//        $(v).parent('td').parent('tr').siblings('div').hide();
        if ($(obj).hasClass('glyphicon-minus')) {
            $(obj).removeClass('glyphicon-minus').addClass('glyphicon-plus');
            $('tr[class^="' + keyyy + '"]').hide();
        } else {
            $(obj).removeClass('glyphicon-plus').addClass('glyphicon-minus');
            $('tr[class^="' + keyyy + '"]').show();
        }
    }
    //删除分类
    function delGoodsCats(id) {
        layer.confirm('您确定要删除该分类吗', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            layer.msg('正在操作，请稍后...', {icon: 16});
            $.post("{:url('Admin/Goodscats/delGoodsCats')}", { id: id}, function (data, textStatus) {
//                console.debug(data);
                if (data > 0) {
                    layer.msg('操作成功', {icon: 1, time: 3000});
                    setTimeout('window.location.href = "{:url(\'Admin/Goodscats/index\')}"',2000);
                } else {
                    layer.msg('操作失败', {icon: 2, time: 3000});
                    setTimeout('window.location.href = "{:url(\'Admin/Goodscats/index\')}"',2000);
                }
            });
        });
    }
</script>
</html>